package cn.sumpu.app.coolsk.dao.impl;

import java.util.List;
import java.util.Map;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;



import cn.sumpu.app.coolsk.dao.OutUserDao;
import cn.sumpu.app.coolsk.domain.OutUser;
import cn.sumpu.app.coolsk.exception.AppBusinessException;

public class OutUserDaoImpl extends SqlSessionDaoSupport implements OutUserDao {

	private final static Logger logger = LoggerFactory
			.getLogger(OutUserDaoImpl.class);

	@Override
	public void insertOutUser(OutUser outUser) throws AppBusinessException {
		try {
			getSqlSession()
					.insert("cn.sumpu.app.coolsk.persistence.OutUserMapper.insert",
							outUser);
		} catch (Exception e) {
			if (logger.isErrorEnabled()) {
				logger.error("insertOutUser failure.", e);
			}
			throw new AppBusinessException("insertOutUser failure.", e);
		}
	}

	@Override
	public void updateOutUser(OutUser outUser) throws AppBusinessException {
		try {
			getSqlSession()
					.insert("cn.sumpu.app.coolsk.persistence.OutUserMapper.update",
							outUser);
		} catch (Exception e) {
			if (logger.isErrorEnabled()) {
				logger.error("updateOutUser  failure.", e);
			}
			throw new AppBusinessException("updateOutUser failure.", e);
		}
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<OutUser> getOutUserByMap(Map<String, Object> map)
			throws AppBusinessException {
		try {
			return getSqlSession()
					.selectList("cn.sumpu.app.coolsk.persistence.OutUserMapper.getOutUserByMap",
							map);
		} catch (Exception e) {
			if (logger.isErrorEnabled()) {
				logger.error("getOutUserByMap  failure.", e);
			}
			throw new AppBusinessException("getOutUserByMap failure.", e);
		}
	}

}
